﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestCrawler.Http;
using TestCrawler.Parser;

namespace TestCrawler.Html
{
    public class HtmlDoc : IHtmlDoc
    {
        private IHttp _request;
        private IParser _parser;
        private IList<string> _links;
        public string Url { get; set; }

        public HtmlDoc(string url)
        {
            _request = new HttpRequest(url);
            this.Url = url;
        }

        public IList<string> GetAllLinks()
        {
            if (_links == null)
            {
                _parser = new UrlParser(_request.ServerUrl, _request.PathUrl, _request.Content);
                _links = _parser.GetHrefs();
            }
            return _links;
        }
    }
}
